<%-- 
    Document   : ViewRoom
    Created on : Apr 4, 2014, 3:05:09 PM
    Author     : mishra
--%>
<%
    try {
        if (session.getAttribute("uid") != null) {
            if (session.getAttribute("Room").toString().equals("1")) {
%>
<%String to = "", status = "", msg = "";%>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Ramgovind Automated System</title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width">
        <link rel="stylesheet" href="/RIT/css/bootstrap.css">
        <link rel="stylesheet" href="/RIT/css/bootstrap-responsive.css">
        <link rel="stylesheet" href="/RIT/css/jquery.fancybox.css">
        <link rel="stylesheet" href="/RIT/css/uniform.default.css">
        <link rel="stylesheet" href="/RIT/css/bootstrap.datepicker.css">
        <link rel="stylesheet" href="/RIT/css/jquery.cleditor.css">
        <link rel="stylesheet" href="/RIT/css/jquery.plupload.queue.css">
        <link rel="stylesheet" href="/RIT/css/jquery.tagsinput.css">
        <link rel="stylesheet" href="/RIT/css/jquery.ui.plupload.css">
        <link rel="stylesheet" href="/RIT/js/tableTools/css/TableTools.css">
        <link rel="stylesheet" href="/RIT/css/chosen.css">
        <link rel="stylesheet" href="/RIT/css/chosen.css">
        <link rel="stylesheet" href="/RIT/css/style.css">
        <link rel="stylesheet" href="/RIT/css/iconfont.css">
        <link rel="stylesheet" href="/RIT/css/lightBox.css">
        <script type="text/javascript">
            function loadHostelRoom()
            {
                //document.getElementById('ILoader').setAttribute("style", "visibility: visible;width: 250px;height: 250px;position: absolute;top: 50%;left:50%;margin-top: -80px;margin-left: -40px;background:url(/RIT/img/loader.gif) no-repeat;z-index: 667999;background-size:200px 200px;");
                var hId=document.getElementById('hid').value;
                var hName=document.getElementById('hname').value;
                
                var xmlhttp; 
                if (window.XMLHttpRequest)
                {
                    xmlhttp=new XMLHttpRequest();
                }
                else
                {
                    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
                xmlhttp.onreadystatechange=function()
                { 
                    if (xmlhttp.readyState==4 && xmlhttp.status==200)
                    {
                        document.getElementById('ctbody').innerHTML = xmlhttp.responseText;
                        document.getElementById('ILoader').removeAttribute("style");
                    }
                }
                xmlhttp.open("POST","/RIT/HostelRoomList?id="+hId+"&name="+hName,true);
                xmlhttp.send();
            }
            function deleteRoomConfirm(id){
                var bb=id.split("--");
                var j=bb[0]+"--b";
                var i=document.getElementById(j).value;
                document.getElementById('myModal').className='modal';
                document.getElementById('delthis').value=i;
                
            }
            function Cancel(){
                document.getElementById('myModal').className='modal hide';
            }         
            function deleteRoom()
            { 
                var roomdetail= document.getElementById('delthis').value.split("/");
                if(roomdetail[1]==roomdetail[2]){
                    var xmlhttp; 
                    if (window.XMLHttpRequest)
                    {
                        xmlhttp=new XMLHttpRequest();
                    }
                    else
                    {
                        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                    }
                    xmlhttp.onreadystatechange=function()
                    {
                        if (xmlhttp.readyState==4 && xmlhttp.status==200)
                        { 
                            var temp=xmlhttp.responseText;
                            if(temp!=0)
                            {
                                var table = document.getElementById(roomdetail[0]);
                                for(var j=4;j>=0;j--)
                                {
                                    table.deleteCell(j);
                                    document.getElementById('myModal').className='modal hide';
                                } 
                            }
                            else
                            {
                                alert("This Data is Used at Some Other Place");
                                document.getElementById('myModal').className='modal hide';
                            }
                        }
                    }
                    xmlhttp.open("POST","/RIT/DeleteRoom?rNo="+roomdetail[0]+"&noOfbed="+roomdetail[1]+"&ava="+roomdetail[2],false);
                    xmlhttp.send();
                }
                else{
                    alert("Room Alloted and can't be deleted");
                }
            }
        </script>
    </head>
    <body onload="loadHostelRoom()">					
        <!--Display Details Divs-->
        <div id="detailDiv" class="white_content"></div>
        <div id="fade" class="black_overlay"></div>
        <%@include file="/topheader.html" %>
        <%@include file="/settingheader.html" %>
        <div class="main">
            <div class="modal hide" id="myModal">
                <div class="modal-header">
                    <button type="button" class="close" onclick="document.getElementById('myModal').className='modal hide'"><img src="/RIT/img/mclose.png"></button>
                    <h3 style=" color: red;">Warning...</h3>
                </div>
                <div class="modal-body">
                    <p>Are you sure to delete?</p>
                </div>
                <div class="modal-footer">
                    <input type="hidden" value="" id="delthis">
                    <a href="#" class="btn btn-primary" onclick="deleteRoom()">Ok</a>
                    <a href="#" class="btn btn-success" onclick="Cancel()">Cancel</a>
                </div>
            </div>
            <div class="container-fluid">
                <%@include file="/Settings/dbsidenav.html"%>
                <div class="content">
                    <%if (session.getAttribute("status") != null) {
                            status = session.getAttribute("status").toString();
                            msg = session.getAttribute("msg").toString();
                    %>
                    <div class="alert alert-success alert-block">
                        <a class="close" data-dismiss="alert" href="#"><img src="/RIT/img/mclose.png"></a>
                        <h4 class="alert-heading"> <%=status%></h4>
                        <%=msg%>

                    </div>
                    <%session.removeAttribute("status");
                            session.removeAttribute("msg");
                        }%>
                    <div class="row-fluid">
                        <div class="box">
                            <div class="box-head tabs">
                                <h3>Room List</h3>
                                <div style="float:right;display:flex">
                                    <div class="input-prepend input-append">
                                        <input type="text" class="input-square" placeholder="Search here..." name="" id="" style="width: 100px; height: 30px"><span class="add-on"><a href="#" class="ficon-search"></a></span>
                                    </div>
                                    <a href="/RIT/Settings/Database/Room.jsp" style="margin-left: 20px;">
                                        <button class="btn btn-success">View Hostel</button>
                                    </a>
                                </div>
                            </div>
                            <div class="box-content box-nomargin">
                                <input type="hidden" id="hid" name="hid" value="<%=request.getParameter("hid")%>">
                                <input type="hidden" id="hname" name="hname" value="<%=request.getParameter("hname")%>">
                                <div class='details pull-left userprofile' style="margin-left: 80px;">
                                    <div class='table table-striped table-detail' style='margin-left: 200px; background-color: #f3f3f3' id='tsal'>
                                        <div style="float: left; margin-top: 10px; margin-bottom: 20px;">
                                            <h4>Hostel Name</h4>
                                        </div>
                                        <div style="float: right; margin-top: 10px; margin-bottom: 20px; color: green">
                                            <h4><%=request.getParameter("hname")%></h4>
                                        </div>
                                    </div>
                                </div>
                                <table class='table table-striped dataTable-noheader dataTable-nofooter table-bordered' style="font-size: 13px;" id="ct">
                                    <thead>
                                        <tr>
                                            <th>Room Number</th>
                                            <th>Number of Beds</th>
                                            <th>Rent</th>
                                            <th>Availability</th>
                                            <th style="width:150px">Action</th>
                                        </tr>
                                    </thead>
                                    <tbody id="ctbody">

                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>	
            </div>
        </div>
    </div>	
    <script src="/RIT/js/jquery.js"></script>
    <script src="/RIT/js/less.js"></script>
    <script src="/RIT/js/bootstrap.min.js"></script>
    <script src="/RIT/js/jquery.uniform.min.js"></script>
    <script src="/RIT/js/bootstrap.timepicker.js"></script>
    <script src="/RIT/js/bootstrap.datepicker.js"></script>
    <script src="/RIT/js/chosen.jquery.min.js"></script>
    <script src="/RIT/js/jquery.fancybox.js"></script>
    <script src="/RIT/js/plupload/plupload.full.js"></script>
    <script src="/RIT/js/plupload/jquery.plupload.queue/jquery.plupload.queue.js"></script>
    <script src="/RIT/js/jquery.cleditor.min.js"></script>
    <script src="/RIT/js/jquery.inputmask.min.js"></script>
    <script src="/RIT/js/jquery.tagsinput.min.js"></script>
    <script src="/RIT/js/jquery.mousewheel.js"></script>
    <script src="/RIT/js/jquery.dataTables.min.js"></script>
    <script src="/RIT/js/jquery.dataTables.bootstrap.js"></script>
    <script src="/RIT/js/jquery.textareaCounter.plugin.js"></script>
    <script src="/RIT/js/ui.spinner.js"></script>
    <script src="/RIT/js/jquery.cookie.js"></script>
    <script src="/RIT/js/tableTools/js/TableTools.min.js"></script>
    <script src="/RIT/js/custom.js"></script><script src="js/demo.js"></script>
    <script src="/RIT/js/iconfont.js"></script>
    <style>
        b{color: rgb(26, 115, 212);}
    </style>

    <script>
        function quickClose(){
            $("#detailDiv").fadeOut(500);
            $("#fade").fadeOut(100);
        }
    </script>
</body>

</html>
<%} else {
%>
<script type="text/javascript">
    alert("You Are Not Authorised");
    window.history.back();
</script>
<%             }
        } else {
            request.setAttribute("msg", "You Are Not Authorised! Please Contact to System Administrator!");
            request.setAttribute("value", "0");
            getServletContext().getRequestDispatcher("/index.jsp").forward(request, response);
        }
    } catch (Exception e) {
        request.setAttribute("msg", "Please Contact to System Administrator!");
        request.setAttribute("value", "0");
        getServletContext().getRequestDispatcher("/index.jsp").forward(request, response);
    }
%>
